import * as types from '../mutations'

import http from '../../http'

const state = {
    vm:''
}

const getters = {

}

const mutations = {
    [types.SET_VM] : (state,payload) => {
        state.vm = payload.vm
    }
}

const actions = {
    login({commit,dispatch,state},payload) {
      http('/api/login', payload, function(res) {
        if(res.code === 0){
          state.vm.$router.push('product')
        }else{
          state.vm.$message.error(res.message)
        }
      })
    },
    islogin({commit,dispatch,state},payload) {
      http('/api/config/islogin', payload, function(res) {
        if(res.code === 0){
          state.vm.$router.push('product')
        }else{
          state.vm.$router.push('/')
        }
      })
    },
}

export default {
    state,
    getters,
    mutations,
    actions

}

